// Fill out your copyright notice in the Description page of Project Settings.

#include "Isalong2.h"
#include "HoldHand.h"


AHoldHand::AHoldHand()
{
	ResourceManager::Init();
	SetBulletContains(1, false);
	_dataPack->_baseHurtValue = 0.2f;
	_dataPack->_hurtType = CWeaponHurtType::Hit;
	_dataPack->_characterFireMontage = ResourceManager::_resourceManager->_handFireCharacterMontage;
	_dataPack->_name = FString("Hand");
	_dataPack->_fireSound = ResourceManager::_resourceManager->_handFireSound;
	_dataPack->_fireShake = ACIsAlongGameMode::_isAlongGameMode->_punchFireShake;
	_itemType = ITEMTYPE_hand;
	_dataPack->_maxContains = 1;
}

void AHoldHand::OnFireBegin()
{
	if (GetBulletContains()<=0)
	{
		return;
	}
	if (_dataPack->_characterFireMontage!=nullptr)
	{
		_weaponOwner->OnPlayMontage(_dataPack->_characterFireMontage);
	}
	if (_dataPack->_fireSound!=nullptr)
	{
		UGameplayStatics::PlaySoundAtLocation(this, _dataPack->_fireSound, GetActorLocation());
	}
	if (_dataPack->_fireShake!=nullptr&&Cast<ACPlayerCharacter>(_weaponOwner)!=nullptr)
	{
		UGameplayStatics::GetPlayerCameraManager(this, 0)->PlayCameraShake(_dataPack->_fireShake);
	}
	SetBulletContains(0, false);
	if (_weaponOwner != nullptr)
	{
		_weaponOwner->OnBulletChangeCallBack();
	}
}

void AHoldHand::OnReloadEnd(int count)
{
	SetBulletContains(_dataPack->_maxContains, false);
	if (_weaponOwner != nullptr)
	{
		_weaponOwner->OnBulletChangeCallBack();
	}
}

int AHoldHand::GetAdditionValue()
{
	return 1;
}

void AHoldHand::SetupAdditionValue(int val)
{
	SetBulletContains(val, false);
}

void AHoldHand::OnFireAnimationEnd()
{
	OnReloadEnd(1);
}

TArray<int> AHoldHand::GetReloadNeedType()
{
	TArray<int> result;
	return result;
}

